import { createStore } from 'vuex'

import createPersistedState from 'vuex-persistedstate'
export default createStore({
  state: {
    permissionList: [],
  },
  mutations: {
    changeState(state, data) {
      Object.keys(data).forEach((key) => {
        return (state[key] = data[key])
      })
    },
  },
  actions: {
    changedata({ commit }, data) {
      commit('changeState', data)
    },
  },
  modules: {},
  // 配置插件
  plugins: [
    // 默认储存在localstorage
    createPersistedState({
      storage: window.sessionStorage,
    }),
  ],
})
